package org.hackystat.ui.projectviewer.gwt.client.common;

import java.util.ArrayList;

import org.hackystat.ui.projectviewer.gwt.client.common.ManagementPanelWidget.Handler;

/**
 * Holds all main panel widgets in one place. Very useful for keeping history track.
 * 
 * @author Pavel Senin.
 */
public class PanelsHolder {

  private ArrayList<Handler> panels = new ArrayList<Handler>();

  // private int selectedPanel = -1;

  /**
   * Finds the handler by given name.
   * 
   * @param panelName the name of the panel to find.
   * @return the handler if the panel found or null if not.
   */
  public Handler find(String panelName) {
    for (int i = 0; i < panels.size(); ++i) {
      Handler handler = (Handler) panels.get(i);
      if (handler.getName().equals(panelName)) {
        return handler;
      }
    }
    return null;
  }

  /**
   * Adds panel to storage.
   * 
   * @param panelHandler The panel handler.
   */
  public void addPanel(Handler panelHandler) {
    panels.add(panelHandler);
  }

}
